import { defineStore } from 'pinia';

export type Theme = 'light' | 'dark' | 'auto'

export const useAppStore = defineStore('appStore', {
  state: () => ({
    // 定义 app 相关的状态
    appName: 'SAT Tutor App',
    budget: 0,
    sectionHeaderShow:true,
    theme: 'light'
  }),
  actions: {
    // 定义 app 相关的操作
    updateAppName(newName: string) {
      this.appName = newName;
    },
    updateShow(show:boolean){
      this.sectionHeaderShow = show;
    },
    setTheme(theme:Theme){
      this.theme = theme;
    }
  },
  // 启用持久化插件，并指定要持久化的属性
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'appStore',
        storage: localStorage,
        paths: ['budget']
      }
    ]
  }
});